Terraform Plugin Framework : ListNestedAttribute Value Conversion Error

Hi

I have created a sample code by following exact foot steps given on the below article for using ListNestedAttributes

Custom Framework Providers

{
"subusers": [
        {
            "user_id": 12345678,
            "username": "chida.test"
        }
    ]
//other values to
}

My struct are like this

type Listsubusers struct {
	Username types.String `tfsdk:"username"`
	UserID   types.Int64  `tfsdk:"user_id"`
}

type DomainsubuserResourceModel struct {
	ID       types.Int64    `tfsdk:"id"`
	Username types.String   `tfsdk:"username"`
	Subusers []Listsubusers `tfsdk:"subusers"`
}

My schema will look like this

"subusers": schema.ListNestedAttribute{
				Computed: true,
				PlanModifiers: []planmodifier.List{
					listplanmodifier.UseStateForUnknown(),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"username": schema.StringAttribute{
							Description: "The subuser username to be associate with the domain",
							Computed:    true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
						},
						"user_id": schema.Int64Attribute{
							Description: "The subuser id to be associate with the domain",
							Computed:    true,
							PlanModifiers: []planmodifier.Int64{
								int64planmodifier.UseStateForUnknown(),
							},
						},
					},
				},
			},

my create function will have code like this to set the state file

for orderItemIndex, orderItem := range domainsubuser.Subusers {
		domainsubnewstate.Subusers[orderItemIndex] = Listsubusers{
			Username: types.StringValue(orderItem.Username),
			UserID:   types.Int64Value(orderItem.UserID),
		}
	}

but getting below error message :frowning:

Error: Value Conversion Error

An unexpected error was encountered trying to build a value. This is always an error in the provider. Please      
│ report the following to the provider developer:
│
│ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types`       
│ package type or a custom type that handles unknown values.
│
│ Path: subusers
│ Target Type: []sendgrid.Listsubusers
│ Suggested Type: basetypes.ListValue

Alternatively tried using Block and it update state file but that ends up an error as below

block count has changed from 0 to 1.

Please any suggestion would be really helpful.

I have solved it by my selft.

schema changed to like this

			"subusers": schema.ListNestedAttribute{
				Computed: true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"username": schema.StringAttribute{
							Description: "The subuser username to be associate with the domain",
							Computed:    true,
						},
						"user_id": schema.Int64Attribute{
							Description: "The subuser id to be associate with the domain",
							Computed:    true,
						},
					},
				},
			},

and Create/Read section used like this

elements := []attr.Value{}
	for _, subuser := range domainsubuser.Subusers {
		elements = append(elements, types.ObjectValueMust(
			map[string]attr.Type{
				"username": types.StringType,
				"user_id":  types.Int64Type,
			},
			map[string]attr.Value{
				"username": types.StringValue(subuser.Username),
				"user_id":  types.Int64Value(subuser.UserID),
			},
		))
	}

	domainsubuserstate.Subusers = types.ListValueMust(
		types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"username": types.StringType,
				"user_id":  types.Int64Type,
			},
		}, elements,
	)

A big thank you to @bendbennett you reference helped me to achieve this.